home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-10-01 | 3.2 KB | 120 lines | [TEXT/R*ch] |
- Notes
- {labels: 'nil, viewFont: 10241} // nil=Unfiled, or specify a folder, e.g., 'Business. remove viewFont for current Styles default
- //ERASE! in order to erase existing entries in this folder first
-
- applic0.nwt -- Slurpee format
- 8/20/94
- Copyright 1994 S. Weyer. All Rights Reserved Worldwide.
- To be distributed only with Newt 2.3 package
-
- A simple introduction to creating applications with Newt. This is a variation
- on a version described in article "Building Native Newton Applications with
- Newt" in PIE Developers, July 1994. see also NewtATut.
-
- To minimize text entry, use the Slurpee utility and a terminal emulator to
- transfer this text file as paragraphs in the Notepad. The folder in 2nd line
- is currently set on nil (Unfiled); select same folder in Newt to load.
-
- Tap Expr button, select expression :doObj('add, 'MyApp).
- Tap Eval, select MyApp, then select each subsequent object in list
- to create application incrementally. See NewtNews.txt. See also NewtATut
-
- ----------
- MyApp
- //:doObj('add,'MyApp)
- {_proto: 'protoApp,
- //viewBounds -- defaults to full screen
- title: "Hello World",
- }
- ----------
- MyApp.myInputProto
- {_proto: 'protoInputLine,
- text: "",
- value: 0,
- viewFlags: 10753, //vVisible + vClickable + vGesturesAllowed + vNumbersAllowed,
- getTextValue: func() // from text, set number value (used by total)
- begin
- self.value := StringToNumber(text);
- if not value then value := 0;
- end,
- viewChangedScript: func(slot,view)
- if slot='text
- then begin
- :getTextValue();
- if total exists then total:update();
- end,
- viewSetupFormScript: func()
- begin
- self.text := clone(text);
- :getTextValue();
- inherited:?viewSetupFormScript();
- end,
- }
- ----------
- MyApp+num1
- {_proto: 'myInputProto,
- viewBounds: RelBounds(130,20,100,20),
- }
- ----------
- MyApp+num2
- {_proto: 'myInputProto,
- viewBounds: RelBounds(130,45,100,20),
- }
- ----------
- MyApp+total
- {_proto: 'protoStaticText,
- viewBounds: RelBounds(130,80,100,16),
- text: "Total", // initial text
- numVars: ['num1, 'num2],
- getValueText: func() // return text from summing field values
- begin
- local tot := 0, field;
- foreach field in numVars // add up num1.value + num2.value etc.
- do tot := tot + GetVariable(self,field).value;
- if round exists and round.viewValue
- then tot := RIntToL(tot);
- NumberStr(tot); // return string
- end,
- update: func()
- SetValue(self,'text,:getValueText()),
- viewSetupFormScript: func()
- begin
- self.text := :getValueText();
- inherited:?viewSeutpFormScript();
- end,
- }
- ----------
- MyApp+round
- {_proto: 'protoCheckbox,
- viewBounds: RelBounds(20,78,50,16),
- text: "Round?",
- valueChanged: func()
- if total exists then total:update(),
- }
- ---------
- MyApp+button
- {_proto: 'protoTextButton,
- viewBounds: RelBounds(100,120,40,16),
- text: "About",
- buttonClickScript: func()
- if float exists
- then float:open()
- else PlaySound(@102), // ROM_funbeep
- }
- ----------
- MyApp+float
- {_proto: 'protoFloatNGo,
- viewBounds: RelBounds(20,140,150,100),
- }
- ----------
- MyApp.float+aboutText
- {viewclass: 'clParagraphView,
- viewBounds: RelBounds(5,5,140,90),
- text: "This demo created by"&&
- userConfiguration.name&
- ", with the help of Newt, the lizard wizard",
- viewFlags: 3, //vReadOnly+vVisible,
- }
- ----------
- BYE!
-